#include "AnAdbServer.h"
#include "AnThread.h"


void AnAdbServer::adbServerManager(QJsonObject an_request, AnCallback *an_callback)
{
	AnThread * work_thread = getAnThread();
	QObject::connect(work_thread, SIGNAL(response(QJsonObject)), an_callback, SLOT(response_slot(QJsonObject)));
	work_thread->setRequest(an_request);
	work_thread->start();
}


AnThread * AnAdbServer::getAnThread()
{
	AnThread * an_thread = new AnThread();
	QObject::connect(an_thread, SIGNAL(threadFinished(AnThread*)), this, SLOT(threadFinished(AnThread*)));
	return an_thread;
}


void AnAdbServer::threadFinished(AnThread *an_thread)
{
	an_thread->quit();
	delete an_thread;
}
